package com.example.rbacmanage.config;

import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import com.github.houbb.sensitive.word.support.allow.WordAllows;
import com.github.houbb.sensitive.word.support.deny.WordDenys;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SensitiveWordConfig {
    @Autowired
    private CustomWordAllow customWordAllow;

    @Autowired
    private CustomWordDeny customWordDeny;

    @Bean
    public SensitiveWordBs sensitiveWordBs() {
        return SensitiveWordBs.newInstance()
                .wordDeny(WordDenys.chains(WordDenys.defaults(),customWordDeny))
                .wordAllow(WordAllows.chains(WordAllows.defaults(),customWordAllow))
                .ignoreCase(true) //忽略大小写
                .ignoreWidth(true) //忽略半角圆角
                .ignoreNumStyle(true) //忽略数字的写法
                .ignoreChineseStyle(true) //忽略中文的书写格式
                .ignoreEnglishStyle(true) //忽略英文的书写格式
                .ignoreRepeat(true) //忽略重复值
                .enableEmailCheck(true) //是否启用邮箱检测
                .enableUrlCheck(true)//是否启用链接检测
                .init();
    }
}
